public class search4 {

    //1.charAt
    //2.indexOf
    public static void main2(String[] args) {

        String s1="123msolm";
        int dex=s1.indexOf('m');
        System.out.println(dex);

        int dex2=s1.indexOf('m',5);
        System.out.println(dex2);

    }


    //3.indexOf(String)
    public static void main3(String[] args) {
        String s1="12dtgijiww";

        int dex=s1.indexOf("gi");
        System.out.println(dex);
    }

    //4.lastIndexOf
    public static void main4(String[] args) {
        String s1="1qwdfgkvsioqwr";


        System.out.println(s1.lastIndexOf('q'));
    }

    //5.toUpperCase
    public static void main5(String[] args) {

        String s1="qwErt";
        System.out.println(s1.toUpperCase());

        System.out.println(s1);
    }

    //6.format
    public static void main6(String[] args) {

        String s=String.format("%d-%d-%d",2022,3,5);
        System.out.println(s);
    }

    //7.replace
    public static void main7(String[] args){

        String s1="qwettthhhffffhf";

        String s2=s1.replace('h','z');

        // System.out.println(s2);

        String s3=s1.replace("hhffff","pppppjdjfoeijfp");
        //System.out.println(s3);

        String s4=s1.replaceFirst("hf","oo");
        //System.out.println(s4);

        String s5=s1.replaceAll("hf","oo");
        System.out.println(s5);
    }

    //8.split——按一定格式拆分字符串
    public static void main8(String[] args) {
        String s1="hello2my2friends";

        String[] s2=s1.split("2",2);

        for(String s:s2){

            //System.out.println(s);
        }

        String s3="192.168.1.1";
        String[] s4=s3.split("\\.");
        for(String p:s4){

            System.out.println(p);
        }
    }


    //9.去除字符串左右两边空格

    public static void main9(String[] args) {

        String s="   hello   word!   ";
        System.out.println("["+s+"]");

        String s2=s.trim();

        System.out.println("["+s2+"]");
    }


    //10.分割字符串
    public static void main(String[] args) {
        String s="qwerrrrrejjj";

        String s1=s.substring(4,7);

        System.out.println(s1);
    }
}


